home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / wp / dana104.zip / INPUT.DAS < prev    next >
Text File  |  1995-12-21  |  1KB  |  74 lines

  1. '
  2. ' Usual string input menu.
  3. '
  4. Const cFileName = "Input.LST"
  5. Dim hMenu%, hMenu2%
  6.  
  7. Main ()
  8.     Dim fp%, nRC%
  9.     Dim ins$
  10.     Dim bBrk%
  11.     Do
  12.         LoadMenu()
  13.         nRC = DoMenu(hMenu)
  14.         Select Case nRC
  15.         Case -1
  16.             bBrk = True
  17.         Case 1000
  18.             'Register a string.
  19.             ins$ = InputBox("Input a string to register.", "", "")
  20.             If Ins$ <> "" Then
  21.                 fp = FOpen(.HomePath + cFileName, "w")
  22.                 If fp <> 0 Then
  23.                     FSeek(fp, 0, 1)
  24.                     FPuts(fp, ins$ + Chr(10))
  25.                     FClose(fp)
  26.                 Else
  27.                     MsgBox("File open was failed.", "", 0)
  28.                 End If
  29.             End If
  30.         Case 1001
  31.             'Edit using the editor.
  32.             FileOpen(.HomePath + cFileName, False)
  33.             bBrk = True
  34.         Case 1002
  35.             'Delete all.
  36.             FKill(.HomePath + cFileName)
  37.         Case 1003
  38.             bBrk = True
  39.         Case Else
  40.             InsertString(GetMenuItem(hMenu, nRC))
  41.             bBrk = True
  42.         End Select
  43.         DiscardMenu(hMenu2)
  44.         DiscardMenu(hMenu)
  45.     Loop Until bBrk = True
  46. End
  47.  
  48. Proc LoadMenu()
  49.     Dim fp%
  50.     fp = FOpen(.HomePath + cFileName, "r")
  51.     hMenu = NewMenu()
  52.     if fp <> 0 Then
  53.         Dim ins$
  54.         Dim I%
  55.         ins$ = FGets(fp)
  56.         Do While ins$ <> ""
  57.             If ins$ <> Chr(10) Then
  58.                 I = I + 1
  59.                 AddMenuItem(hMenu, Left$(ins$, Len(ins$)-1), I)
  60.             End If
  61.             ins$ = FGets(fp)
  62.         Loop
  63.         FClose(fp)
  64.     End If
  65.     AddMenuItem(hMenu, "", -1)
  66.     Dim hMenu2%
  67.     hMenu2 = AddMenuItem(hMenu, "&Edit", 0)
  68.         AddMenuItem(hMenu2, "&Add", 1000)
  69.         AddMenuItem(hMenu2, "&Edit", 1001)
  70.         AddMenuItem(hMenu2, "&Delete All", 1002)
  71.     AddMenuItem(hMenu, "&Cancel", 1003)
  72. End Proc
  73.  
  74.